<%@page import="com.wanmait.movies.vo.Discuss"%>
<%@page import="java.util.ArrayList"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<%
String path=request.getContextPath();
%>
<style type="text/css">
#size{
width:600px;
height:650px;
border:1px black solid;
margin: auto;
}
.list{
width:598px;
height:200px;
margin: auto;
}
.discuss{
width:576px;
height:48px;
padding-left:0px; 
float: left;
border:1px solid black;
margin: auto;

}
.movie{
width:598px;
height:150px;
margin: auto;
border:solid 1px black;
}
.images{
width:72px;
height:98px;
float: left;
}
.images img{
height:102px;
}
.information{
width:400px;
height:98px;
float: left;
}
.movietype{
width:505px;
height:48px;
float: left;
border:1px solid black;
}
.movietype div{
float: left;
width:100px;
}
.moviepinglun{
overflow: hidden;
width:380px;
height:48px;
}
.fenye{
width:300px;
height: 30px;
margin: auto;
text-align: center;
}
#ThisPage{
width:30px;
}
a:link,a:visited{ 
 text-decoration:none;  /*超链接无下划线*/ 
} 
.danxuan{
width:20px;
height:100px;
float: left;
padding-top: 70px;
}
.user{
width:598px;
height:50px;
border:black 1px solid;
margin: auto;
}
.user div{
float: left;
}
.userimage img{
width:30px;
height:30px;
border-radius: 50%;
}
.discusstime{
line-height:50px;
font-size: 10px;
color:red;
}
</style>
<script type="text/javascript" src="<%=path %>/js/jquery-3.5.1.min.js"></script>
<script type="text/javascript">
$(function () {
	$("#ThisPage").blur(function(){//这是text查找页数的
		var thispage=$("#ThisPage").val();
		var pagemax=$("#NextPage").attr("PageMax");
		if(thispage>pagemax){
			thispage=pagemax;
			$("#ThisPage").val(pagemax);
		}else{
			location.href="<%=path%>/UserServlet?action=discuss&thispage="+thispage;
		}
		
	});
});
$(function () {
	$("#LastPage").click(function(){//上一页
		//alert("11654");
		var thispage=$("#ThisPage").val();
		thispage--;
		if(thispage<1){
			thispage=1;
		}else{
			location.href="<%=path%>/UserServlet?action=discuss&thispage="+thispage;
		}
	});
});
$(function () {
	$("#NextPage").click(function(){//下一页
		var thispage=$("#ThisPage").val();
		var pagemax=$("#NextPage").attr("pagemax");
		      thispage++;
		    //  alert(pagemax);
		if(thispage>pagemax){
			thispage=pagemax;
		}else{
			location.href="<%=path%>/UserServlet?action=discuss&thispage="+thispage;
		}
		});
});
$(function () {//全选框 点中全选
	$("#size").on("click","#allbox",function(){
		var flag=$("#allbox").prop("checked");
		if(flag==true){
			$(".everyone").prop("checked",true);
		}else{
			$(".everyone").prop("checked",false);
		}
		 
	});
});
$(function () {
	$("#alldelete").click(function(){//批量删除评论
	//	alert("21131");
		var cks= $(".everyone:checked");
		var str="";
		cks.each(function(){
			var gid=$(this).attr("gid");
			str=str+","+gid;
			$(this).parent().parent().parent().remove();//父类div div的父类list
		});
		str=str.substring(1);
		if(str!=""){
			$.ajax({
		         url:"<%=path%>/UserServlet",
		         type:"get",
		         data:{action:"discussdelete",discussid:str},
		         success:function (mes){
		        	 $("#alldelete").prop("checked",false);
		         }
				});
			} else{
			$(".Tips").html("请勾选评论");
		}
	});
})


</script>
</head>
<body>
<div id="size"><!-- 最大的div -->
<div><input type="checkbox" id="allbox"  /><a href="javascript:" id="alldelete" >勾选删除评论</a><span class=Tips></span></div>
<%
ArrayList<Discuss>alldiscuss=(ArrayList<Discuss>)request.getAttribute("alldiscuss");
for(Discuss discuss:alldiscuss){
%>
<div>
<div class="user">
<div class="userimage"><img src="<%=path %>/images/<%=discuss.getUserId().getUserFaceimage() %>"/></div><!-- 评论人头像 -->
<div class="username"><%=discuss.getUserId().getUserName() %></div><!-- 评论人的名字-->
<div class="discusstime"><%=discuss.getDiscussTime() %></div><!-- 评论时间 -->
</div>
<div class="list"><!-- 每一行就是一个div，就是我的评论加上电影 -->
<div class="danxuan"><input type="checkbox" gid="<%=discuss.getId() %>" class="everyone"/></div>
<div class="discuss"><%=discuss.getMovieDiscuss() %></div><!-- 我的评论，超出部分有滚动条 -->
<div class="movie"><!-- 整个的电影内容  -->
<div class="images"><a href="javascript:"><img src="<%=path %>/images/<%=discuss.getMovieId().getMovieImage() %>" /></a></div><!-- 电影的缩略图 -->
<div class="information"><!-- 电影的内容和简介，分内容和简介上下两个div -->
<div class="movietype">
<div><a href="javascript:"><%=discuss.getMovieId().getMovieName() %></a></div><!-- 电影名字 -->
<div><a href="javascript:"><%=discuss.getMovieId().getMovieTypeId().getMovieType() %></a></div><!-- 电影类型 -->
</div><!-- 电影名，电影类型 -->
<div class="moviepinglun"><%=discuss.getMovieId().getMovieIntroduction() %><a href="javascript:">&gt;&gt;更多</a></div><!-- 我评论的电影的简介，超出部分点击更多去往电影首页查看 -->
</div>
</div>
</div>
</div>
 <%
}
 %>
 </div>
<div class="fenye">
<a href="javascript:" id="LastPage">上一页</a>
<input type="text" id="ThisPage" value="<%=request.getAttribute("ThisPage") %>" />
<a href="javascript:" id="NextPage" pagemax="<%=request.getAttribute("PageMax")%>">下一页</a>
</div>
</body>
</html>